    <div class="head"><h5 class="iList">Directory Type</h5></div>
     <form action="<?php echo url_for('directory_types/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" id="valid" class="mainForm" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
     	<div class="rowElem noborder">
     	<label for="name">Name:</label>
     		<div class="formRight"><input type="text" name="directory_type[name]" value="<?php echo $form->getObject()->getName()?>"  class="validate[required]"  id="directory_type_name"/></div>
     		<div class="fix"></div>
     	</div>
     	<div class="fix"></div>
        <input type="button" value="Save" class="greyishBtn submitForm" id="save" />
        <div class="fix"></div>
     </form>
     
     
<script type="text/javascript">
	$("#save").click(function (event){
        submitForm();
	})

	$("form#valid").submit(function (event){
        event.preventDefault();
        submitForm();
    })

	function submitForm(){
        var str=$('form#valid').serialize();

        $.ajax({type: 'POST', url:' <?php echo url_for('directory_types/'.($form->getObject()->isNew() ? 'create' :'update').
        (!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : ''))?>', script:true, cache:false, data:  str, 
        beforeSend: function(){
            if ($("#name").attr("value") == "") return false; },
                success: function(data) {
                     $('#master_div').html(data);
                     $('#directory_type_name').attr('value',"");
                 } });
	}

</script>     
